Skip to main content

Embedding Stories

This documentions will guide you with adding the Nudge Stories into your applicatiom

Android View

If your android app is xml based, you can add the Stories into Your app like this

Adding Views

<com.nudgenow.nudgecorev2.experiences.stories.components.NudgeStoryTray
android:layout_width="match_parent"
android:id="@+id/{YOUR_VIEW_ID}"
android:tag="{YOUR_VIEW_TAG}"
android:layout_height="wrap_content"/>
val storyContainer = NudgeStoryTray(
context,
headingLightModeColor = "#FF0000", //optional
headingDarkModeColor = "#00FF00", //optional
subheadingDarkModeColor = "#FFFFFF", //optional
subheadingLightModeColor = "#000000" //optional
)
val layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
storyContainer.orientation = LinearLayout.HORIZONTAL
storyContainer.layoutParams = layoutParams
storyContainer.tag = "YOUR_TAG"
yourview.addView(storyContainer)
warning

Make sure you add a id to the view

Jetpack Compose

AndroidView(
factory = { ctx ->
val storyContainer = NudgeStoryTray(
ctx ,
headingLightModeColor = "#FF0000", //optional
headingDarkModeColor = "#00FF00", //optional
subheadingDarkModeColor = "#FFFFFF", //optional
subheadingLightModeColor = "#000000" //optional
).apply {
val _layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
orientation = LinearLayout.HORIZONTAL
layoutParams = _layoutParams
tag = "YOUR_TAG"
}
storyContainer
},
)

To display targeted stories within your app, integrate the Nudge SDK and use the Nudge.getInstance().track("event_name") method to log specific user actions. Then, leverage the Nudge Dashboard to define which stories, identified by tags, should be presented in designated Story Containers based on those logged events.